home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 855 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.2 KB  |  56 lines

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: double const declarations
  5. Date: 26 Mar 1996 16:23:07 GMT
  6. Organization: ?
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <9603261135.AA22454@lts.sel.alcatel.de>
  9. References: <Pine.A32.3.91.960325093715.29874A-100000@zorglub.cae.ca>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. In-Reply-To: dak's message of 25 Mar 1996 10:09:28 PST
  12. Content-Length: 1279
  13. X-Lines: 33
  14. Originator: clamage@taumet
  15.  
  16. In article <Pine.A32.3.91.960325093715.29874A-100000@zorglub.cae.ca>
  17. dak <pierreba@poster.cae.ca> writes:
  18.  
  19. |> I've just encountered a problem in one of our template design and wondered
  20. |> what could be done about it. It concerns const reference return value from
  21. |> a templated member function, for example:
  22.  
  23. |> template <class T> class SmartPtr
  24. |> {
  25. |>     // ... whatever:
  26. |> public:
  27. |>     const T & Dereference ();
  28. |> };
  29.  
  30. |> The problem arise when T is instantiated with a Container of constants:
  31.  
  32. |> SmartPtr<const int> a;
  33.  
  34. |> Here we have a double const which is not supported by the compiler, nor the
  35. |> standard, I believe.  Is there a fix or should we abandon all hope of using
  36. |> const returns in templates ?
  37.  
  38. The draft standard forbids two explicit const's.  If the duplicate
  39. Const result from typedef's, etc., it's OK.  (I don't know if the
  40. actual words mention template instantiation types, but if they don't
  41. I'm sure that it is an editorial oversight, and not the intent.)
  42.  
  43. --
  44. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  45. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  46. Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
  47.                 -- A la recherche d'une activitΘ dans une region francophone
  48.  
  49.  
  50.  
  51. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  52. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  53. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  54. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  55. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  56.